package com.mallcai.bigdata.ladon.service.report.impl;

import com.mallcai.bigdata.ladon.dpl.entity.dashboard.SqlRunLogStatic;
import com.mallcai.bigdata.ladon.dpl.entity.report.SqlRunLog;
import com.mallcai.bigdata.ladon.dpl.mapper.report.SqlRunLogMapper;
import com.mallcai.bigdata.ladon.service.report.ISqlRunLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by oneape<oneape15@163.com>
 * Created 2019-07-15 20:19.
 * Modify:
 */
@Service
public class SqlRunLogService implements ISqlRunLogService {

    @Autowired
    private SqlRunLogMapper sqlRunLogMapper;

    /**
     * 根据Id获取
     *
     * @param logId Long
     * @return SqlRunLog
     */
    @Override
    public SqlRunLog getById(Long logId) {
        return sqlRunLogMapper.findById(logId);
    }

    /**
     * 根据条件查询日志
     *
     * @param params Map
     * @return List
     */
    @Override
    public List<SqlRunLog> getByParams(Map<String, Object> params) {
        if (params == null) {
            params = new HashMap<>();
        }
        return sqlRunLogMapper.getByParams(params);
    }

    @Override
    public void insert(SqlRunLog sqlRunLog) {
        sqlRunLogMapper.insert(sqlRunLog);
    }

    @Override
    public List<SqlRunLogStatic> getRunLogStatic() {
        return sqlRunLogMapper.getRunLogStatic();
    }

    @Override
    public List<SqlRunLogStatic> getYesterdayRunLogStatic() {
        return sqlRunLogMapper.getYesterdayRunLogStatic();
    }

    @Override
    public int deleteLogOneWeekAgo() {
        return sqlRunLogMapper.deleteLogOneWeekAgo();
    }

    /**
     * 获取今天的访问量
     *
     * @return int
     */
    @Override
    public int getTodayVisitSize() {
        return sqlRunLogMapper.getTodayVisitSize();
    }
}
